<?php

namespace app\company\controller\user_profile\userArchive\crisisTesting;

use app\company\service\user_profile\userArchive\crisisTesting\CrisisTestingService;
use app\BaseController;
use app\common\Message;

class CrisisTesting extends BaseController
{
    use Message;

    /**
     * 危机干预概况
     * @return bool|string
     */
    public function getOverview(): bool|string
    {
        $param = $this->request->param();
        $param['uid'] = $this->userData['id'];
        try {
            $crisisTesting = new CrisisTestingService($this->app);
            if(!$crisisTesting->getOverview($param)) throw new \Exception($crisisTesting->getMessage());
            return success($crisisTesting->getResult(),$crisisTesting->getMessage());
        } catch (\Exception $e) {
            return error($e->getMessage(),$e->getCode(),[
                'line' => $e->getLine(),
                'file' => $e->getFile()
            ]);
        }
    }

    /**
     * 获取个人自评记录
     * @return bool|string
     */
    public function getRecode(): bool|string
    {
        $param = $this->request->param();
        $param['uid'] = $this->userData['id'];
        try {
            $crisisTesting = new CrisisTestingService($this->app);
            if(!$crisisTesting->getCrisisRecode($param)) throw new \Exception($crisisTesting->getMessage());
            return success($crisisTesting->getResult(),$crisisTesting->getMessage());
        } catch (\Exception $e) {
            return error($e->getMessage(),$e->getCode(),[
                'line' => $e->getLine(),
                'file' => $e->getFile()
            ]);
        }
    }
}